package com.springcloud;

import java.util.logging.Level;
import java.util.logging.Logger;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;


/**
 * 
* @ClassName: ServiceMiyaApplication 
* @Description: spring cloud sleuth(服务链路追踪)
* @author nbc
* @date 2017年12月22日 下午2:50:01 
*
 */
@SpringBootApplication
@RestController
public class ServiceMiyaApplication {

	public static void main(String[] args) {
		SpringApplication.run(ServiceMiyaApplication.class, args);
	}
	
	   private static final Logger LOG = Logger.getLogger(ServiceMiyaApplication.class.getName());


	    @RequestMapping("/hi")
	    public String home(){
	        LOG.log(Level.INFO, "hi is being called");
	        return "hi i'm miya!";
	    }

	    @RequestMapping("/miya")
	    public String info(){
	        LOG.log(Level.INFO, "info is being called");
	        return restTemplate.getForObject("http://localhost:8988/info",String.class);
	    }

	    @Autowired
	    private RestTemplate restTemplate;

	    @Bean
	    public RestTemplate getRestTemplate(){
	        return new RestTemplate();
	    }
}
